package com.ibeeking.found.content.b.rest.controller.v1;

import com.ibeeking.found.content.b.rest.service.IBroadcastLuckyService;
import com.ibeeking.found.content.service.common.param.BroadcastLuckyParam;
import com.ibeeking.found.content.service.common.query.BroadcastLuckyQuery;
import com.ibeeking.found.content.service.common.vo.BroadcastLuckyVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName BroadcastController控制器
 * @Description
 * @Author ibeeking
 * @Date 2022-02-18 14:11
 **/
@RestController
@RequestMapping("/b/broadcast/v1/lucky")
public class BroadcastLuckyController {

    @Resource
    private IBroadcastLuckyService broadcastLuckyServiceImpl;


    /**
     * --------抽奖活动
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "活动列表")
    @PostMapping(value = "/list")
    public List<BroadcastLuckyVO> luckyList(@RequestBody BroadcastLuckyQuery broadcastLuckyQuery) {
        return broadcastLuckyServiceImpl.list(broadcastLuckyQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "活动添加")
    @PostMapping(value = "/add")
    public Boolean luckyAdd(@RequestBody @Validated BroadcastLuckyParam broadcastLuckyParam) {
        return broadcastLuckyServiceImpl.add(broadcastLuckyParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "活动修改")
    @PostMapping(value = "/modify")
    public Boolean luckyModify(@RequestBody @Validated BroadcastLuckyParam broadcastLuckyParam) {
        return broadcastLuckyServiceImpl.modify(broadcastLuckyParam);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "活动查看")
    @GetMapping(value = "/view/{id}")
    public BroadcastLuckyVO luckyView(@PathVariable("id") Long id) {
        return broadcastLuckyServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "活动删除")
    @PostMapping(value = "/del/{id}")
    public Boolean luckyDel(@PathVariable("id") Long id) {
        return broadcastLuckyServiceImpl.del(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "活动状态修改")
    @PostMapping(value = "/changeStatus/{id}/{status}")
    public Boolean luckyChangePublishStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return broadcastLuckyServiceImpl.changePublishStatus(id, status);
    }
}
